from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from .models import *
from . import serializers
# Create your views here.


class show_ding(APIView):
    def get(self,request):
        ding = Ding.objects.all()
        dings = serializers.ding_serializers(instance=ding,many=True)
        return Response({
            'code':200,
            'dings':dings.data
        })

class login(APIView):
    def post(self,request):
        name = request.data['name']
        User.objects.filter(name=name).first()
        return Response({
            'code':200
        })

class show_goods(APIView):
    def get(self,request):
        good = Goods.objects.all()
        goods = serializers.goods_serializers(instance=good, many=True)
        return Response({
            'code': 200,
            'goods': goods.data
        })
